Skip to content

Handle for SIGTERM #561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Handle for SIGTERM #561

wants to merge 2 commits into from

Conversation

shayonj
Copy link

@shayonj shayonj commented Apr 29, 2024

In containerized workloads, it's common to receive a SIGTERM signal when a pod or task is shutting down. Currently, when this occurs, the rake task throws a SignalException and returns a status code of 1. This behavior can be misinterpreted by container orchestration systems (like Fargate, Kubernetes, etc.) as an error, rather than a graceful exit.

This PR proposes that, when a SIGTERM signal is received by a rake task, it should return an exit code of 143. This exit code is the standard response for a SIGTERM, indicating a proper shutdown was acknowledged and handled gracefully.

I only added this for SIGTERM, but should be extensive for other handlers too if needed in future.

Related: #272

@shayonj shayonj marked this pull request as ready for review April 29, 2024 20:29
@shayonj shayonj force-pushed the s/term-sginal branch 8 times, most recently from 581e40e to 4bdd3ae Compare April 29, 2024 21:39
@hsbt hsbt force-pushed the s/term-sginal branch from 64ef69f to 1b1ee63 Compare May 30, 2025 05:45
@shayonj
Copy link
Author

shayonj commented May 31, 2025

👋🏾 @hsbt thanks for taking a look, just updated the branch. Let me know if you have any feedback 🙏🏾

@@ -850,5 +852,12 @@ def set_default_options # :nodoc:
options.trace_rules = false
end

def setup_signal_handling
Signal.trap("TERM") do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should only trap signals which are supported on the platform.

Suggested change
Signal.trap("TERM") do
return unless Signal.list.include?('TERM')
Signal.trap("TERM") do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants